/**
 * @description 地址数据操作
 */
const Address = require('../../models/Address')
!(async () => {
  /* await Address.create({
    username:'zhansan',
    city: '北京',
    department: 'xx小区',
    houseNumber: '门牌号',
    name: '张三',
    phone: '18612345678'
  }) */
  //获取个人收获地址列表
  /* const result=await Address.find({username:'zhansan'}).sort({updatedAt:-1})
  console.log(result); */

  //根据id查找单个收获地址
 /*  const id = '60951a7447446964c02fd059'
  const result = await Address.findById(id)
  console.log(result); */

  //更新收货地址
  const id = '60951a7447446964c02fd059'
  const newData={
    city: '南京',
    department: 'xx小区1',
    houseNumber: '门牌号1',
    name: '张三1',
    phone: '18612345671'
  }
  const result=await Address.findOneAndUpdate({_id:id,username:'zhansan'},newData,{new:true})
  console.log(result);

})()